// 常用操作
const commonOperation = function (){

    /**
     * 回退
     */
    function goloc(){
        history.go(-1);
        location.reload();
    }

    /**
     * 根据时间戳生成唯一标识
     */
    function guid() {
        let date = new Date();
        date = date.getTime() + '';

        return date.slice(0,7)+date.slice(10,13)
        // return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
        //     let r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
        //     return v.toString(16);
        // });
    }

    /**
     * 时间比较方法  - 生成一个新的时间
     *  @val 提前或推后的时间
     */
    function getHourDate(val){

        let num = parseInt(val);

        let date = new Date();
        date.setMinutes(date.getMinutes() + num);

        let hour = date.getHours(); // H
        let min = date.getMinutes(); // m
        // let seconds = date.getSeconds(); // s
        let seconds = "00";

        console.log(hour+":"+min+":"+seconds);
        if (hour < 10){
            hour = "0"+hour;
        }
        if (min < 10){
            min = "0"+min;
        }
        let mytime = hour+":"+min+":"+seconds

        console.log("getHourDate -- ",mytime)

        return mytime;
    }



    return {
        getHourDate,
        goloc,
        guid
    }
}()

export default commonOperation;
